{% extends "business/customer.html" %}
{% block content %}

<table class="table table-hover table-condensed table-bordered">
    <thead>
        <tr>
            <td bgcolor="#C9C9C9">客户ID</td>
            <td bgcolor="#C9C9C9">客户名称</td>
            <td bgcolor="#C9C9C9">客户地址</td>
            <td bgcolor="#C9C9C9">联系人</td>
            <td bgcolor="#C9C9C9">联系电话</td>
            <td bgcolor="#C9C9C9">联系邮箱</td>
            <td bgcolor="#C9C9C9">客户详情</td>
            <td bgcolor="#C9C9C9">操作</td>
        </tr>
    </thead>
    <tbody>
    {% for customer in customers %}
        <tr class="success">
            <td>{{ customer.id }}</td>
            <td><a href="{% url "show_customer" customer.name %}">{{ customer.name }}</a></td>
            <td>{{ customer.address }}</td>
            <td>{{ customer.contact }}</td>
            <td>{{ customer.telenumber }}</td>
            <td>{{ customer.email }}</td>
            <td><a href="{% url "show_customer" customer.id %}">查看详情</a></td>
            <td><button type="button" class="btn btn-primary btn-xs" id="Customer_{{ customer.id }}">删除</button></td>
        </tr>

        <script>
            $(function () {
                $("#Customer_{{ customer.id }}").click(function () {
                    if(confirm("确定删除 客户名称: {{ customer.name }} 客户? 该客户的订单和ticket信息也将被一起删除。")){
                        $.get("/business/del_customer?customer_id={{ customer.id }}", function () {
                            window.location.replace("/business");
                        });
                    }
                })
            })
        </script>
    {% endfor %}
    </tbody>
</table>

{% endblock %}